package org.example.service;

import org.example.pojo.Student;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * @Description:
 * @Author: WengYu
 */
@Service
public class StudentService{

    private static List<Student> students = new ArrayList<>();

    static {
        students.add(new Student(1L,"张三"));
        students.add(new Student(2L,"李四"));
    }

    public List<Student> findAll(){
        return students;
    }

    public Student findById(long id) {
        Student student = null;
        for (Student student1 : students) {
            if (student1.getId().equals(id)){
                student = student1;
            }
        }
        return student;
    }
}
